let username = sessionStorage.getItem("username");
if (username == null) {
    console.log(username)
    window.location.href = "/html/login.html";
    window.open("/html/login.html", '_top');
}

const baseUrl = 'http://localhost:8081'

function myAjax(url, data, type) {
    let result ;
    console.log(baseUrl+url)
    // ajax属于异步请求,默认开启异步执行
    $.ajax({
        url: baseUrl+url,
        data: data,
        type: type,
        async: false,//关闭异步
        dataType: 'json',
        success: function (res) {
            result = res;
        }
    })
    return result;
}

function getAjax(url, data) {
    let result = {};
    // ajax属于异步请求,默认开启异步执行
    $.ajax({
        url: baseUrl+url,
        data: data,
        type: 'get',
        async: false,//关闭异步
        dataType: 'json',
        success: function (res) {
            result = res;
        }
    })
    return result;
}


function postAjax(url, data) {
    let result = {};
    // ajax属于异步请求,默认开启异步执行
    $.ajax({
        url: url,
        data: data,
        type: 'post',
        async: false,//关闭异步
        dataType: 'json',
        success: function (res) {
            result = res;
        }
    })
    return result;
}
